//
//  CollectionHeaderView.swift
//  OverseasOnlineShopping
//
//  Created by 唐先才 on 16/3/8.
//  Copyright © 2016年 唐先才. All rights reserved.
//

import UIKit

class CollectionHeaderView: UICollectionReusableView {
    
    var dataArray: NSMutableArray = []
    var adCollectionView: ADCollectionView?
    var waitView: WaitLoadView?
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        createUI()
    }

    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
    }
    
    func createUI() {
        adCollectionView = ADCollectionView(frame: CGRect(x: 0, y: 0, width: WIDTH, height: 200))
        guard let adCollectionView = self.adCollectionView else {
            print("调用自定义的头视图失败")
            return
        }
        addSubview(adCollectionView)
        
        waitView = WaitLoadView(frame: self.frame)
        guard let waitView = self.waitView else {
            print("滚动视图调用正在加载失败")
            return
        }
        self.addSubview(waitView)
    }
    
    func passDataArray(dataArray: NSMutableArray) {
        guard let adCollectionView = self.adCollectionView else {
            print("调用自定义的头视图失败")
            return
        }
        guard let waitView = self.waitView else {
            print("滚动视图调用正在加载失败")
            return
        }
        waitView.removeFromSuperview()
        adCollectionView.configWithArray(dataArray)
    }
}
